package com.ythook.mentor.repository;

import com.ythook.mentor.entity.MentorCalendar;
import com.ythook.mentor.entity.Trainings;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Optional;

@Repository
public interface TrainingsRepository extends JpaRepository<Trainings,Long> {

    @Modifying
    @Query(value = "delete from Trainings m where m.mentorId=?1")
    Integer deleteByMentorId(Long mentorId);

    @Query(value = "select t from Trainings t where t.userId=?1")
    List<Trainings> findAllByUserId(Long userId);

    List<Trainings> findByUserIdAndTrainingsStatus(Long userId, String trainingsStatus);

    List<Trainings> findByUserIdAndTrainingsStatusNot(Long userId, String trainingsStatus);


    List<Trainings> findByMentorIdAndTrainingsStatus(Long mentorId, String trainingsStatus);

    List<Trainings> findByMentorIdAndTrainingsStatusNot(Long mentorId, String trainingsStatus);

    List<Trainings> findByMentorId(Long mentorId);

    @Query(value = "select t from Trainings t where t.mentorId=?1")
    List<Trainings> findAllByMentorId(Long mentorId);

}
